﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AppFx.Tokenization;

namespace Tests.Tokenization
{
    public class TokenizedExpressionValidator
    {
        public ITokenizer Tokenizer { get; set; }

        public TokenizedExpressionValidator(ITokenizer tokenizer)
        {
            Tokenizer = tokenizer;
        }

        public bool Validate(TokenExpression expression)
        {
            List<IToken> tokens = Tokenizer.Tokenize(expression.Expression).ToList();
            if (tokens.Count != expression.Expected.Count)
                return false;
            for (int i = 0; i < tokens.Count; i++)
            {
                if (!tokens[i].Type.Equals(expression.Expected[i]))
                    return false;
            }
            return true;
        }
    }
}
